/**
 * Promise.map(
    Iterable<any>|Promise<Iterable<any>> input,
    function(any item, int index, int length) mapper,
    [Object {concurrency: int=Infinity} options]
   ) -> Promise
 */

const Promise = require('bluebird');
const arr1 = [];
const arr2 = [3,4,5,6,7,8];
// for (let i = 0; i < arr2.length; i++) {
//   arr1.push(arr2[i]);
// }
// Promise.all(arr1).then(() => {
//   console.log('done');
// })
// console.log('array:' + arr1);
const fn = [];
for (let i = 0; i < arr2.length; i++) {
  fn.push(arr2[i]);
}
Promise.map(arr2, function(fn) {
  console.log('fn:' + fn);
  return fn;
}, { concurrency: 3 }).then(function() {
  console.log('DONE！！！');
})
arr1.push(fn);
console.log('map done:' + arr1); // map done:3,4,5,6,7,8